<?php

/*
+--------------------------------------------------------------------------
|   Invision Power Board
|   =============================================
|   by Matthew Mecham
|   (c) 2001 - 2006 Invision Power Services, Inc.
|   
|   =============================================
|   
|   
+---------------------------------------------------------------------------
|   > $Date: 2007-08-21 17:48:41 -0400 (Tue, 21 Aug 2007) $
|   > $Revision: 1099 $
|   > $Author: bfarber $
+---------------------------------------------------------------------------
|
|   > PORTAL PLUG IN MODULE: Recent topics
|   > Module written by Matt Mecham
|   > Date started: Monday 1st August 2005 (16:22)
+--------------------------------------------------------------------------
*/

/**
* Portal Plug In Module
*
* This module displays the recently posted topic title and
* first post.
*
* @package		InvisionPowerBoard
* @subpackage	PortalPlugIn
* @author		Matt Mecham
* @copyright	Invision Power Services, Inc.
* @version		2.1
*/

/**
* Portal Plug In Module
*
* This module displays the recently posted topic title and
* first post.
* Each class name MUST be in the format of:
* ppi_{file_name_minus_dot_php}
*
* @package		InvisionPowerBoard
* @subpackage	PortalPlugIn
* @author		Matt Mecham
* @copyright	Invision Power Services, Inc.
* @version		2.1
*/

if ( ! defined( 'IN_IPB' ) )
{
	print "<h1>Incorrect access</h1>You cannot access this file directly. If you have recently upgraded, make sure you upgraded 'admin.php'.";
	exit();
}

class ppi_users
{
	/**
	* IPS Global object
	*
	* @var string
	*/
	var $ipsclass;

	/**
	* Array of portal objects including:
	* good_forum, bad_forum
	*
	* @var array
	*/
	var $portal_object = array();
	
	/*-------------------------------------------------------------------------*/
 	// INIT
	/*-------------------------------------------------------------------------*/
 	/**
	* This function must be available always
	* Add any set up here, such as loading language and skins, etc
	*
	*/
 	function init()
 	{
 	}
 	
 	/*-------------------------------------------------------------------------*/
 	// SHOW RECENT POSTS X
	/*-------------------------------------------------------------------------*/
	function top_users_list()
 	{
 		//-----------------------------------------
 		// INIT
 		//-----------------------------------------
 		$html  = "";
 		$limit = $this->ipsclass->vars['portal_top_user_number'] ? $this->ipsclass->vars['portal_top_user_number'] : 9;
 		
 		$this->ipsclass->DB->cache_add_query( 'portal_get_top_user', 
 											  array('field_id' => $this->ipsclass->vars['dkm_repid'],
 											  		'limit' => $limit )
 											 );
		$this->ipsclass->DB->cache_exec_query();
		
		$memberlist = "";
		while($member = $this->ipsclass->DB->fetch_row()) {
			$member['avatar'] = $this->ipsclass->get_avatar( $member['avatar_location'], $this->ipsclass->member['view_avs'], '45x45', $member['avatar_type'] );
			$member['member_url'] = strtolower($member['name']);
			$memberlist .= $this->ipsclass->compiled_templates['skin_portal']->tmpl_top_users_row($member);
		}
		
 		return $this->ipsclass->compiled_templates['skin_portal']->tmpl_top_users($memberlist);
 	}
 	
 	function users_birthday_list() {
 		//-----------------------------------------
 		// INIT
 		//-----------------------------------------
 		$html  = "";
		
		$day = date('d');
 		$month = date('m');
 		
 		$limit = $this->ipsclass->vars['portal_user_birthday_number'] ? $this->ipsclass->vars['portal_user_birthday_number'] : 6;

 		$this->ipsclass->DB->cache_add_query( 'portal_get_user_birthday', 
 											  array('day' 	=> $day,
 											  		'month' => $month,
 											  		'limit' => $limit )
 											 );
 		
		$this->ipsclass->DB->cache_exec_query();
		
		while($user = $this->ipsclass->DB->fetch_row()) {
			$user['avatar'] = $this->ipsclass->get_avatar( $user['avatar_location'], $this->ipsclass->member['view_avs'], '80x80', $user['avatar_type'] );
			$memberlist .= $this->ipsclass->compiled_templates['skin_portal']->tmpl_top_users_row($user);
		}
		
		if($memberlist) $html = $this->ipsclass->compiled_templates['skin_portal']->tmpl_users_birthday($memberlist);
 		
		return $html;
 	}
}

?>